var SceneSwitch = function(options) {
	this.ctx=options.ctx;
	this.editor=options.editor;
	
	this.containerId = options.containerId;
	this.mutex = options.mutex;
	if(this.mutex){
		this.sceneEnabledEdit = options.sceneEnabledEdit;
		this.sceneEnabledTips = !this.sceneEnabledEdit;
	}else{
		this.sceneEnabledEdit = options.sceneEnabledEdit;
		this.sceneEnabledTips = options.sceneEnabledTips;
	}
	
	this.isShow=true;
	this.enabledEdit;
	this.enabledTips;
	this.init();
	return this;
}

SceneSwitch.prototype.init=function(){
	var _this = this;
	_this.createSwitch();
}

SceneSwitch.prototype.createSwitch=function(){
	var _this = this;
	var content = '<button id="sceneOpenEdit" type="button" title="是否可编辑" class="scene-btn header-btn" data-lock="fa fa-lock" data-unlock="fa fa-unlock"><i class="fa fa-lock"></i></button>   '
		+' <div class="fly-mid"></div> <button id="sceneOpenTips" type="button" title="是否开启Tips" class="scene-btn header-btn" data-lock="fa fa-file-text" data-unlock="fa fa-file-text-o"><i class="fa fa-file-text"></i></button>';
	$('#'+_this.containerId).append(content);
	_this.enabledEdit = $('#sceneOpenEdit');
	_this.enabledTips = $('#sceneOpenTips');
	_this.sceneSwitchRefresh();
	_this.onEnabledEdit();_this.onEnabledTips();
}

SceneSwitch.prototype.onEnabledEdit=function(){
	var _this = this;
	_this.enabledEdit.click(function() {
		if(_this.mutex){
			_this.enabledTips.children("i").attr('class',_this.sceneEnabledEdit?_this.enabledTips.data('unlock'):_this.enabledTips.data('lock'));
			_this.sceneEnabledTips=_this.sceneEnabledEdit;
			_this.editor.sceneEnabledTips=_this.sceneEnabledTips;
		}
		_this.enabledEdit.children("i").attr('class',!_this.sceneEnabledEdit?_this.enabledEdit.data('unlock'):_this.enabledEdit.data('lock'));
		_this.sceneEnabledEdit=!_this.sceneEnabledEdit;
		_this.editor.sceneEnabledEdit=_this.sceneEnabledEdit;
		_this.sceneSwitchRefresh();
	});
}

SceneSwitch.prototype.onEnabledTips=function(){
	var _this = this;
	_this.enabledTips.click(function() {
		if(_this.mutex){
			_this.enabledEdit.children("i").attr('class',_this.sceneEnabledTips?_this.enabledEdit.data('unlock'):_this.enabledEdit.data('lock'));
			_this.sceneEnabledEdit=_this.sceneEnabledTips;
			_this.editor.sceneEnabledEdit=_this.sceneEnabledEdit;
		}
		_this.enabledTips.children("i").attr('class',!_this.sceneEnabledTips?_this.enabledTips.data('unlock'):_this.enabledTips.data('lock'));
		_this.sceneEnabledTips=!_this.sceneEnabledTips;
		_this.editor.sceneEnabledTips=_this.sceneEnabledTips;
		_this.sceneSwitchRefresh();
	});
}

SceneSwitch.prototype.sceneSwitchRefresh=function(){
	var _this = this; 
	_this.enabledEdit.children("i").attr('class',_this.sceneEnabledEdit?_this.enabledEdit.data('unlock'):_this.enabledEdit.data('lock'));
	_this.enabledTips.children("i").attr('class',_this.sceneEnabledTips?_this.enabledTips.data('unlock'):_this.enabledTips.data('lock'));
}

SceneSwitch.prototype.open=function(){
	var _this = this;
	_this.isShow=true;
	$("#"+_this.containerId).css("display","");
	_this.sceneSwitchRefresh();
	_this.editor.sceneEnabledEdit=_this.sceneEnabledEdit;
	_this.editor.sceneEnabledTips=_this.sceneEnabledTips;
}

SceneSwitch.prototype.colse=function(){
	var _this = this;
	_this.isShow=false;
	$("#"+_this.containerId).css("display","none");
	_this.editor.sceneEnabledEdit=false;
	_this.editor.sceneEnabledTips=true;
}